export default class EconomySystem {
    constructor(scene) {
        this.scene = scene;
        this.gold = 0;
        this.setupEventListeners();
    }

    setupEventListeners() {
        this.scene.events.on('add_gold', amount => {
            this.gold += amount;
            this.updateUI();
        });

        this.scene.events.on('spend_gold', (amount, callback) => {
            if (this.gold >= amount) {
                this.gold -= amount;
                callback(true);
            } else {
                callback(false);
            }
            this.updateUI();
        });
    }

    updateUI() {
        this.scene.registry.set('gold', this.gold);
        this.scene.events.emit('gold_updated');
    }
}